﻿# Add general actions here, if any.

offer_vassalization_interaction = {
	category = interaction_category_vassal
	icon = icon_vassal

	desc = offer_vassalization_interaction_desc

	ai_targets = {
		ai_recipients = neighboring_rulers
	}
	ai_target_quick_trigger = {
		adult = yes
	}
	ai_frequency = 12

	is_shown = {
		scope:actor = {
			is_landed = yes
		}
		scope:recipient = {
			NOT = { this = scope:actor }
			is_playable_character = yes
			OR = {
				AND = {
					is_independent_ruler = yes
					is_tributary = no
				}
				is_tributary_of_suzerain_or_above = scope:actor
			}
			highest_held_title_tier < scope:actor.highest_held_title_tier
			NOR = { 
				government_has_flag = cannot_be_vassal_or_liege 
				government_has_flag = government_is_herder
			}
		}
		# Temujin cannot make Jamukha his subject once he leaves him
		NOT = {
			scope:actor = {
				has_variable = had_mpo_temujin_flavor_0010
				var:had_mpo_temujin_flavor_0010 ?= scope:recipient
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_confederation_member = no
		}
		scope:recipient = {
			is_at_war = no
			is_confederation_member = no

			custom_description = {
				text = was_recently_granted_independence
				NOT = {
					has_opinion_modifier = {
						modifier = granted_independence_opinion
						target = scope:actor
					}
				}
			}
		}
	}

	greeting = positive
	notification_text = OFFER_VASSALIZATION_INTERACTION_NOTIFICATION

	cost = {
		influence = {
			value = 0
			if = {
				limit = { scope:influence_send_option = yes }
				add = scope:actor.medium_influence_value
				desc = INFLUENCE_INTERACTION_ACCEPTANCE_SEND_OPTION
			}
		}
	}

	ai_min_reply_days = 5
	ai_max_reply_days = 10

	ai_accept = {
		base = -100 # -50
		# MAIN
		# Heretic/Infidel modifier.
		# Tier difference modifier.
		# Dejure modifier.
		# Distant/Remote Realm modifier.
		# Military power difference modifier.

		# MINOR
		# Rivalry modifier.
		# Same Dynasty modifier.
		# Cultural/Cultural Group modifiers.
		# Ageism modifier vs kids.
		# Ruler Legitimacy modifier.
		# Claimant modifier.
		# FP3 Piety Level modifier.

		# OPINION SCALES
		# Dread
		# Compare Opinion modifier.
		
		# PERKS
		modifier = { # Perk boost
			desc = offer_vassalization_true_ruler_perk_tt
			trigger = {
				scope:actor = { has_perk = true_ruler_perk }
			}
			add = true_ruler_value
		}
		modifier = { # Education 5 boost
			desc = offer_vassalization_education_diplomacy_5_tt
			trigger = {
				scope:actor = { has_trait_with_flag = offer_vassalisation_25 }
			}
			add = 25
		}

		# EVENTS - temporary bonuses gained by events
		modifier = {
			desc = event_bonus_to_vassal_accept_tt
			trigger = {
				scope:actor = { has_character_modifier = event_bonus_to_vassal_accept }
			}
			add = 20
		}


		# STRUGGLES - bonus gained by successful Sway scheme during the Persian Struggle
		modifier = {
			desc = fp3_persian_struggle_previously_swayed_tt
			trigger = {
				scope:recipient = {
					has_opinion_modifier = {
						modifier = scheme_sway_and_compelled_to_submit_opinion
						target = scope:actor
					}
				}
			}
			add = 20
		}

		modifier = {
			desc = fp3_rekindler_of_iran_modifier_reason
			trigger = {
				AND = { 
					scope:actor = { dynasty ?={ has_dynasty_modifier = fp3_rekindler_of_iran_modifier } }
					scope:recipient = { culture = { has_cultural_pillar = heritage_iranian } }
				}
			}
			add = 20
		}
		
		# OBEDIENCE
		modifier = {
			desc = obedient_interaction_reason
			trigger = {
				is_obedient_to = scope:actor
			}
			add = 20
		}

		modifier = { # Cultural Acceptance
			add = offer_vassalage_acceptance_value
			desc = cultural_acceptance_interaction_reason
			trigger = {
				scope:actor = {
					NOR = {
						has_same_culture_as = scope:recipient
						government_has_flag = government_is_nomadic # Nomads do not care about Culture
						has_trait = nomadic_philosophy
					}
					culture = {
						cultural_acceptance = { target = scope:recipient.culture value <= 90 }
					}
				}
			}
		}

		# MAIN
		modifier = { #Different faith, no pluralism.
			desc = offer_vassalization_interaction_aibehavior_differentfaith_tt
			trigger = {
				scope:actor = {
					NOR = { # Nomads do not care about Faith
						government_has_flag = government_is_nomadic
						has_trait = nomadic_philosophy
					}
				}
				scope:recipient = {
					NOR = { #Of two different faiths AND the potential vassal's faith is not pluralistic.
						faith = scope:actor.faith
						faith = { has_doctrine = doctrine_pluralism_pluralistic }
					}
				}
			}
			add = {
				value = -40
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_hostile_level
							}
						}
					}
					add = -40
				}
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_evil_level
							}
						}
					}
					add = -40
				}
			}
		}

		modifier = { #Different faith, pluralism.
			desc = offer_vassalization_interaction_aibehavior_differentfaith_tt
			trigger = {
				scope:actor = {
					NOR = { # Nomads do not care about Faith
						government_has_flag = government_is_nomadic
						has_trait = nomadic_philosophy
					}
				}
				scope:recipient = {
					NOT = {
						faith = scope:actor.faith
					}
					NOT = {
						scope:actor.faith = { has_doctrine = doctrine_pluralism_pluralistic }
					}
					faith = { has_doctrine = doctrine_pluralism_pluralistic }
				}
			}
			add = {
				value = -20
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_hostile_level
							}
						}
					}
					add = -20
				}
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_evil_level
							}
						}
					}
					add = -20
				}
			}
		}

		modifier = { #Different faith, both have pluralism.
			desc = offer_vassalization_interaction_aibehavior_differentfaith_tt
			trigger = {
				scope:actor = {
					NOR = { # Nomads do not care about Faith
						government_has_flag = government_is_nomadic
						has_trait = nomadic_philosophy
					}
				}
				scope:recipient = {
					NOT = {
						faith = scope:actor.faith
					}
					scope:actor.faith = { has_doctrine = doctrine_pluralism_pluralistic }
					faith = { has_doctrine = doctrine_pluralism_pluralistic }
				}
			}
			add = {
				value = -10
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_hostile_level
							}
						}
					}
					add = -10
				}
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_evil_level
							}
						}
					}
					add = -10
				}
			}
		}
		modifier = { #I am a King!
			desc = offer_vassalization_interaction_aibehavior_amkingtier_tt
			trigger = {
				scope:recipient = { highest_held_title_tier = tier_kingdom }
			}
			add = {
				value = -50
				if = {
					limit = {
						scope:recipient = {
							OR = {
								government_has_flag = government_is_republic
								government_has_flag = government_is_theocracy
							}
						}
					}
					add = -50
				}
				if = {
					limit = {
						scope:recipient.sub_realm_size >= 5
					}
					add = -50
				}
				if = {
					limit = {
						scope:recipient.sub_realm_size >= 10
					}
					add = -100
				}
			}
		}
		modifier = { #We just fought against each other.
			desc = offer_vassalization_interaction_aibehavior_recent_war_tt
			trigger = {
				scope:recipient = {
					any_truce_holder = {
						this = scope:actor
					}
				}
				# Ensure the truce wasn't purchased and is indeed from a war
				scope:actor = {
					NOT = {
						has_purchased_truce_with_char = { TARGET = scope:recipient }
					}
				}
				scope:recipient = {
					NOT = {
						has_purchased_truce_with_char = { TARGET = scope:actor }
					}
				}
			}
			add = -50
		}
		modifier = { #I fought an independence war against you.
			desc = offer_vassalization_interaction_aibehavior_independence_war_tt
			trigger = {
				scope:recipient = {
					exists = var:independence_war_former_liege
					var:independence_war_former_liege = scope:actor
				}
			}
			add = -200
		}
		modifier = { # I am Tribal and you are not
			desc = interaction_tribal_vs_nontribal
			trigger = {
				scope:recipient = {
					government_has_flag = government_is_tribal
				}
				scope:actor = {
					NOT = { government_has_flag = government_is_tribal }
				}
			}
			add = -20
		}
		modifier = { # You are Tribal and I am not
			desc = interaction_nontribal_vs_tribal
			trigger = {
				scope:actor = {
					government_has_flag = government_is_tribal
				}
				scope:recipient = {
					NOT = { government_has_flag = government_is_tribal }
				}
			}
			add = -20
		}
		modifier = { # I am Nomadic and you are Nomadic
			desc = interaction_is_nomadic
			trigger = {
				scope:recipient = {
					government_has_flag = government_is_nomadic
				}
				scope:actor = {
					government_has_flag = government_is_nomadic
				}
			}
			add = -50
		}
		modifier = { # I am Nomadic and you are not
			desc = interaction_nomadic_vs_nonnomadic
			trigger = {
				scope:recipient = {
					government_has_flag = government_is_nomadic
				}
				scope:actor = {
					NOT = { government_has_flag = government_is_nomadic }
				}
			}
			add = -75
		}
		modifier = { # You are Nomadic and I am not
			desc = interaction_nonnomadic_vs_nomadic
			trigger = {
				scope:actor = {
					government_has_flag = government_is_nomadic
				}
				scope:recipient = {
					NOT = { government_has_flag = government_is_nomadic }
				}
			}
			add = -75
		}
		modifier = { # Isolationist tradition
			desc = isolationist_reason
			trigger = {
				NOT = {
					scope:actor.culture = scope:recipient.culture
				}
				scope:recipient.culture = {
					has_cultural_tradition = tradition_isolationist
				}
			}
			add = -20
		}
		modifier = { #Bankrupt
			desc = bankrupt_reason
			trigger = {
				scope:actor.gold <= -1
			}
			add = -100
		}
		modifier = { #Wide difference in rank
			desc = offer_vassalization_interaction_aibehavior_widetitletier_tt
			trigger = {
				scope:actor = {
					tier_difference = {
						target = scope:recipient
						value > 1
					}
				}
			}
			add = 10
		}
		modifier = { # Allied
			desc = offer_vassalization_interaction_aibehavior_allied_tt
			trigger = {
				scope:recipient = {
					is_allied_to = scope:actor
				}
			}
			add = 20
		}
		modifier = { # Is the Rightful Liege of recipient
			desc = offer_vassalization_interaction_aibehavior_rightfulliegetitleholder_tt
			trigger = {
				scope:actor = { is_rightful_liege_of = scope:recipient }
			}
			add = 20
		}
		modifier = { #Is not the Rightful Liege of recipient
			desc = offer_vassalization_interaction_aibehavior_not_rightfulliegetitleholder_tt
			trigger = {
				NOT = {
					scope:actor = { is_rightful_liege_of = scope:recipient }
				}
			}
			add = -20
		}
		modifier = { # Encircled
			desc = offer_vassalization_interaction_aibehavior_encircled_tt
			trigger = {
				scope:recipient = {
					NOT = {
						any_neighboring_top_liege_realm_owner = {
							NOT = {
								this = scope:actor
							}
						}
					}
					NOT = {
						any_realm_county = {
							is_coastal_county = yes
						}
					}
				}
			}
			add = 20
		}
		modifier = { #Distant Realm — Overseas Connection
			desc = offer_vassalization_interaction_aibehavior_distantrealm_tt
			trigger = {
				scope:actor = {
					character_is_realm_neighbor = scope:recipient
					NOT = { #Ibiza should want to be a vassal of Mallorca, etc.
						character_is_land_realm_neighbor = scope:recipient
						scope:actor = { is_rightful_liege_of = scope:recipient }
					}
				}
			}
			add = -100
		}
		modifier = { #Distant Realm — No Connection
			desc = offer_vassalization_interaction_aibehavior_distantrealm_tt
			trigger = {
				scope:actor = {
					NOT = {
						character_is_realm_neighbor = scope:recipient
					}
				}
				scope:recipient.capital_province = { squared_distance = { target = scope:actor.capital_province value < 200000 } }
			}
			add = -250
		}
		modifier = { #Remote Realm.
			desc = offer_vassalization_interaction_aibehavior_remoterealm_tt
			trigger = {
				scope:actor = {
					NOT = {
						character_is_realm_neighbor = scope:recipient
					}
				}
				scope:recipient.capital_province = { squared_distance = { target = scope:actor.capital_province value >= 200000 } }
			}
			add = -500
		}
		modifier = {
			desc = offer_vassalization_interaction_aibehavior_power_tt
	  	  	add = {
				value = 1
				subtract = {
					value = scope:recipient.max_military_strength # Intended for recipient to use max, to avoid having vassalizations become too easy for weakened realms
					divide = { value = scope:actor.current_military_strength min = 1 }
				}
				multiply = 20
				ceiling = yes
	  		}
		}
		modifier = {
			desc = offer_vassalization_interaction_aibehavior_vassal_opinion_tt
			trigger = {
				scope:actor = {
				number_of_powerful_vassals >= 1
				}
			}

	  	  	add = {
				value = 0
				scope:actor = {
					every_powerful_vassal = {
						if = {
							limit = {
								save_temporary_opinion_value_as = {
									name = vassal_opinion
									target = scope:actor
								}
							}
							add = scope:vassal_opinion
						}
					}

					if = {
						limit = {
							number_of_powerful_vassals > 0
						}
						divide = number_of_powerful_vassals
					}
					else = {
						divide = 5
					}
				}

				divide = 5
	  		}
		}

		# MINOR
		modifier = { #Friend modifier.
			desc = offer_vassalization_interaction_aibehavior_friend_tt
			trigger = {
				scope:recipient = {
					has_relation_friend = scope:actor
					NOT = { has_relation_best_friend = scope:actor }
				}
			}
			add = 10
		}
		modifier = { #Best Friend modifier.
			desc = offer_vassalization_interaction_aibehavior_best_friend_tt
			trigger = {
				scope:recipient = {
					has_relation_best_friend = scope:actor
				}
			}
			add = 20
		}
		modifier = { #Lover modifier.
			desc = interaction_lover
			trigger = {
				scope:recipient = {
					has_relation_lover = scope:actor
					NOT = { has_relation_soulmate = scope:actor }
				}
			}
			add = 10
		}
		modifier = { #Soulmate modifier.
			desc = interaction_soulmate
			trigger = {
				scope:recipient = {
					has_relation_soulmate = scope:actor
				}
			}
			add = 20
		}
		modifier = { #Rivalry modifier.
			desc = offer_vassalization_interaction_aibehavior_rival_tt
			trigger = {
				scope:recipient = {
					has_relation_rival = scope:actor
					NOT = { has_relation_nemesis = scope:actor }
				}
			}
			add = -100
		}
		modifier = { #Nemesis modifier.
			desc = offer_vassalization_interaction_aibehavior_nemesis_tt
			trigger = {
				scope:recipient = {
					has_relation_nemesis = scope:actor
				}
			}
			add = -1000
		}
		modifier = { #Same Dynasty modifier.
			desc = offer_vassalization_interaction_aibehavior_dynasty_tt
			trigger = {
				scope:recipient = {
					dynasty = scope:actor.dynasty
				}
			}
			add = 5
		}

		modifier = { # Same language
			add = 5
			desc = speaks_same_language_interaction_reason
			trigger = {
				scope:actor = {
					knows_language_of_culture = scope:recipient.culture
				}
			}
		}

		modifier = { # Iberian Struggle, less likely for outsiders to vassalize inside
			add = -35
			desc = iberian_struggle_reason_reason
			trigger = {
				scope:actor = {
					NOT = {
						any_character_struggle = { is_struggle_type = iberian_struggle }
					}
				}
				scope:recipient = {
					any_character_struggle = { is_struggle_type = iberian_struggle }
				}
			}
		}

		modifier = { #Ageism modifier vs kids.
			desc = offer_vassalization_interaction_aibehavior_child_tt
			trigger = {
				scope:actor = {
					age < 12
				}
				scope:recipient = {
					age > 16
				}
			}
			add = -5
		}
		modifier = { #Illegitimacy modifier.
			desc = offer_vassalization_interaction_aibehavior_illegitimate_tt
			trigger = {
				scope:actor = {
					OR = {
						AND = {
							has_trait = bastard
							scope:recipient = {
								faith = { NOT = { has_doctrine = doctrine_bastardry_none } }
							}
						}
						has_trait = denounced
						has_trait = disinherited
					}
				}
			}
			add = -10
		}

		modifier = { #Claimant modifier.
			desc = offer_vassalization_interaction_aibehavior_claimant_tt
			trigger = {
				scope:actor.primary_title = {
					scope:recipient = {
						has_claim_on = prev
					}
				}
			}
			add = -20
		}

		modifier = { # Ambitious
			desc = TAKE_THE_VOWS_AMBITIOUS
			trigger = {
				scope:recipient = {
					has_trait = ambitious
				}
			}
			add = -20
		}

		modifier = { # Paranoid
			desc = INTERACTION_PARANOID
			trigger = {
				scope:recipient = {
					has_trait = paranoid
				}
			}
			add = -20
		}

		modifier = { # Arrogant
			desc = INTERACTION_ARROGANT
			trigger = {
				scope:recipient = {
					has_trait = arrogant
				}
			}
			add = -20
		}

		modifier = { # Fickle
			desc = INTERACTION_FICKLE
			trigger = {
				scope:recipient = {
					has_trait = fickle
				}
			}
			add = -10
		}

		modifier = { # Stubborn
			desc = INTERACTION_STUBBORN
			trigger = {
				scope:recipient = {
					has_trait = stubborn
				}
			}
			add = -10
		}

		modifier = { # Trusting
			desc = TAKE_THE_VOWS_TRUSTING
			trigger = {
				scope:recipient = {
					has_trait = trusting
				}
			}
			add = 5
		}

		modifier = { # Content
			desc = INTERACTION_CONTENT
			trigger = {
				scope:recipient = {
					has_trait = content
				}
			}
			add = 5
		}

		modifier = { # FP3 modifier.
			desc = GENERIC_YOUR_PIETY_LEVEL_MODIFIER
			trigger = { scope:actor = { any_character_struggle = { has_struggle_phase_parameter = piety_level_affects_vassalage_acceptance } } }
			add = {
				value = {
					value = scope:actor.piety_level
					subtract = low_piety_level
				}
				multiply = 10
			}
		}

		# OPINION INFLUENCE
		modifier = {
			add = intimidated_external_reason_value
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 1
				}
			}
			desc = INTIMIDATED_REASON
		}
		modifier = {
			add = cowed_external_reason_value
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 2
				}
			}
			desc = COWED_REASON
		}
		opinion_modifier = { #Compare Opinion modifier - Clans care more about opinion
			trigger = {
				scope:actor = {
					government_has_flag = government_is_clan
				}
				scope:recipient = {
					government_has_flag = government_is_clan
				}
			}
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.7
		}
		opinion_modifier = { #Compare Opinion modifier.
			trigger = {
				OR = {
					scope:actor = {
						NOT = { government_has_flag = government_is_clan }
					}
					scope:recipient = {
						NOT = { government_has_flag = government_is_clan }
					}
				}
			}
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.35
		}

		# DIPLOMATIC COURT GRANDEUR BONUS
		modifier = {
			trigger = {
				scope:actor = {
					has_royal_court = yes
					has_dlc_feature = royal_court
					has_court_type = court_diplomatic
					court_grandeur_current_level >= 1
				}
			}
			add = {
				value = scope:actor.court_grandeur_current
				if = {
					limit = { # Reduce the bonus if you are below your expected level
						scope:actor = {
							court_grandeur_current_level < court_grandeur_minimum_expected_level
						}
					}
					multiply = 0.15
				}
				else = {
					multiply = 0.3
				}
			}
			desc = DIPLOMATIC_COURT_ACCEPTANCE_INCREASE_REASON
		}

		# CONTRACT OPTIONS
		modifier = {
			add = 60
			scope:recipient = {	government_has_flag = government_is_feudal }
			scope:religious_exemption = yes
			desc = CONTRACT_RELIGIOUS_EXEMPTION_REASON
		}
		modifier = {
			add = 30
			scope:recipient = {	government_has_flag = government_is_clan }
			scope:religious_exemption_clan = yes
			desc = CONTRACT_RELIGIOUS_EXEMPTION_REASON
		}
		modifier = {
			add = 30
			scope:recipient = {	government_has_flag = government_is_feudal }
			scope:low_obligations = yes
			desc = CONTRACT_LOW_TAXES_REASON
		}
		modifier = {
			add = -40
			scope:recipient = {	government_has_flag = government_is_feudal }
			scope:high_obligations = yes
			desc = CONTRACT_HIGH_TAXES_REASON
		}

		# INSPECTION BONUSES
		modifier = {
			desc = "INSPECTION_REASON"
			add = 5
			scope:recipient = {
				has_variable_list = lesser_inspection_bonus
				is_target_in_variable_list = {
					name = lesser_inspection_bonus
					target = scope:actor
				}
			}
		}
		modifier = {
			desc = "INSPECTION_REASON"
			add = 10
			scope:recipient = {
				has_variable_list = inspection_bonus
				is_target_in_variable_list = {
					name = inspection_bonus
					target = scope:actor
				}
			}
		}
		modifier = {
			desc = "INSPECTION_REASON_REWARD"
			add = 10
			scope:recipient = {
				has_variable_list = inspection_reward
				is_target_in_variable_list = {
					name = inspection_reward
					target = scope:actor
				}
			}
		}
		modifier = {
			desc = "INSPECTION_REASON_REWARD_FOCUSED"
			add = 10
			scope:actor = { has_character_modifier = inspection_reward_focused_vassal_acceptance }
		}

		# LOW LEGITIMACY
		modifier = {
			desc = "LOW_LEGITIMACY_REASON"
			add = -25
			scope:actor = {
				has_legitimacy_flag = reduced_vassalization_acceptance
			}
		}
		modifier = {
			desc = "LOW_LEGITIMACY_REASON"
			add = -50
			scope:actor = {
				has_legitimacy_flag = very_reduced_vassalization_acceptance
			}
		}
		modifier = {
			desc = "LOW_LEGITIMACY_REASON"
			add = -75
			scope:actor = {
				has_legitimacy_flag = massively_reduced_vassalization_acceptance
			}
		}

		# HIGH LEGITIMACY
		modifier = {
			desc = "HIGH_LEGITIMACY_REASON"
			add = 25
			scope:actor = {
				has_legitimacy_flag = increased_vassalization_acceptance
			}
		}
		modifier = {
			desc = "HIGH_LEGITIMACY_REASON"
			add = 50
			scope:actor = {
				has_legitimacy_flag = very_increased_vassalization_acceptance
			}
		}
		modifier = {
			desc = "HIGH_LEGITIMACY_REASON"
			add = 75
			scope:actor = {
				has_legitimacy_flag = extra_increased_vassalization_acceptance
			}
		}

		# INFLUENCE
		modifier = {
			add = 25
			scope:influence_send_option = yes
			desc = INFLUENCE_INTERACTION_ACCEPTANCE_SEND_OPTION
		}

		#HISTORICALLY ADMIN PEOPLES WANT TO BE ADMIN
		modifier = {
			add = 30
			scope:actor = {
				government_has_flag = government_is_administrative
			}
			scope:recipient = {
				culture = {
					OR = {
						this = culture:greek
						any_parent_culture_or_above = {
							this = culture:greek
						}
						this = culture:han
						any_parent_culture_or_above = {
							this = culture:han
						}
					}
				}
			}
			
			desc = "HISTORICAL_ADMIN_REASON"
		}

		modifier = { # AI-only weights, keep the pope from vassalizing too fast
			trigger = {
				exists = faith:catholic.religious_head
				faith:catholic.religious_head = scope:actor
				scope:actor = { is_ai = yes }
			}
			add = -50
		}

		modifier = {
			trigger = {
				scope:actor = {
					has_variable = severed_head_vassalization
					var:severed_head_vassalization = {
						this = scope:recipient
					}
				}
			}
			add = 200
			desc = COWED_BY_SEVERED_HEAD_MODIFIER
		}

		# Nanboku-cho Period
		modifier = {
			desc = SHOGUNATE_VASSALIZATION_NANBOKUCHO_ENEMY_SUPPORTER
			trigger = {
				shogunate_is_nanbokucho_period_trigger = yes
				OR = {
					AND = {
						scope:actor = { has_trait = northern_court }
						scope:recipient = {
							OR = {
								has_trait = southern_court
								has_trait = third_force
							}
						}
					}
					AND = {
						scope:actor = { has_trait = southern_court }
						scope:recipient = {
							OR = {
								has_trait = northern_court
								has_trait = third_force
							}
						}
					}
					AND = {
						scope:actor = { has_trait = third_force }
						scope:recipient = {
							OR = {
								has_trait = northern_court
								has_trait = southern_court
							}
						}
					}
				}
			}
			add = -50
		}
		modifier = {
			desc = SHOGUNATE_VASSALIZATION_NANBOKUCHO_PENALTY
			trigger = {
				shogunate_is_nanbokucho_period_trigger = yes
				NOR = {
					AND = {
						scope:actor = { has_trait = northern_court }
						scope:recipient = {
							OR = {
								has_trait = southern_court
								has_trait = third_force
							}
						}
					}
					AND = {
						scope:actor = { has_trait = southern_court }
						scope:recipient = {
							OR = {
								has_trait = northern_court
								has_trait = third_force
							}
						}
					}
					AND = {
						scope:actor = { has_trait = third_force }
						scope:recipient = {
							OR = {
								has_trait = northern_court
								has_trait = southern_court
							}
						}
					}
				}
			}
			add = -25
		}

		#ALL these modifiers are also used in impress_intent_vassalization_acceptance_value, keep them synced
	}

	# Low starting obligations
	send_option = {
		is_shown = {
			scope:recipient = {
				government_has_flag = government_is_feudal
			}
		}
		flag = low_obligations
		localization = low_obligations
	}

	# Medium starting obligations
	send_option = {
		is_shown = {
			scope:recipient = {
				government_has_flag = government_is_feudal
			}
		}
		flag = normal_obligations								# If selected then scope:flag_name will be set to yes
		localization = normal_obligations				# Loc_key for option label
		starts_enabled = { always = yes	}				# Trigger for whether this should be on when the window opens. If not defined, defaults to off

	}

	# High starting obligations
	send_option = {
		is_shown = {
			scope:recipient = {
				government_has_flag = government_is_feudal
			}
		}
		flag = high_obligations								# If selected then scope:flag_name will be set to yes
		localization = high_obligations					# Loc_key for option label
	}

	# Low starting obligations + religious exemption
	send_option = {
		is_shown = {
			scope:recipient = {
				government_has_flag = government_is_feudal
			}
		}
		is_valid = {
			NOT = { scope:recipient.faith = scope:actor.faith }
		}
		flag = religious_exemption
		localization = religious_exemption
	}

	# Religious exemption, for clans
	send_option = {
		is_shown = {
			scope:recipient = {
				government_has_flag = government_is_clan
			}
		}
		is_valid = {
			NOT = { scope:recipient.faith = scope:actor.faith }
		}
		flag = religious_exemption_clan
		localization = religious_exemption
	}

	# Nothing, for clans
	send_option = {
		is_shown = {
			scope:recipient = {
				government_has_flag = government_is_clan
			}
		}
		is_valid = {
			always = yes
		}
		flag = no_exemption_clan
		localization = no_exemption
	}

	send_option = { # EP3 Influence
		is_shown = {
			scope:actor = {
				government_has_flag = government_has_influence
			}
		}
		is_valid = {
			scope:actor = { influence >= medium_influence_value }
		}
		flag = influence_send_option
		localization = TRADE_INFLUENCE_FOR_BETTER_AI_ACCEPTANCE
	}

	send_options_exclusive = yes

	on_accept = {
		shogunate_check_catalyst_shogunate_vassalize_effect = yes
		offer_vassalization_interaction_effect = yes
		scope:actor = {
			trigger_event = char_interaction.0001

			## Remove bonus, it's been used
			if = {
				limit = { has_character_modifier = event_bonus_to_vassal_accept }
				remove_character_modifier = event_bonus_to_vassal_accept
			}

			if = { # FP3
				limit = { any_character_struggle = { has_struggle_phase_parameter = offer_vassalization_removes_disloyalty } }
				scope:recipient = { remove_trait = disloyal }
			}
		}
	}

	on_decline = {
		scope:actor = {
			trigger_event = char_interaction.0002
		}
	}

	ai_potential = {
		is_adult = yes
		is_independent_ruler = yes
		highest_held_title_tier > tier_county
	}

	ai_will_do = {
		base = 100

		# AI prefers to receive higher obligations from their vassals when possible.
		modifier = {
			factor = 3
			scope:normal_obligations = yes
		}

		modifier = {
			factor = 4
			scope:high_obligations = yes
		}

		# Cynical rulers are happy to offer religious protection to potential vassals, but only when it makes them accept a vassalization offer they would otherwise refuse.
		# Zealous rulers become increasingly reluctant to offer religious protection, as they want to enforce religious homogeneity in their realm.
		modifier = {
			add = {
				value = ai_zeal
				multiply = -2
				max = 1
			}
			scope:religious_exemption = yes
		}


		modifier = { # If the recipient is a player, do not bother sending
			factor = 0
			scope:recipient = {
				is_ai = no
			}
		}
	}
}

offer_fealty_interaction = {
	category = interaction_category_vassal
	icon = icon_liege

	desc = offer_fealty_interaction_desc

	is_shown = {
		scope:recipient = {
			NOT = { this = scope:actor }
			is_landed = yes
			is_independent_ruler = yes # Target has to be independent
		}
		scope:actor.highest_held_title_tier < scope:recipient.highest_held_title_tier
		scope:actor = {
			is_landed = yes
			is_independent_ruler = yes # You have to be independent - This check exists to prevent a lot of edge-cases where you can change liege
			NOT = { government_has_flag = cannot_be_vassal_or_liege }
			is_confederation_member = no
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			is_imprisoned = no
			is_at_war = no
		}
		scope:recipient = {
			custom_description = {
				text = "offer_fealty_neighboring_condition"
				subject = scope:recipient
				OR = {
					any_neighboring_and_across_water_top_liege_realm_owner = { this = scope:actor }
					any_held_title = {
						is_de_jure_liege_or_above_target = scope:actor.capital_barony
					}
				}
			}
			#making sure that if this gov types got land you won't be able to swear fealty to them
			NOR = {
				government_has_flag = government_is_landless_adventurer
				government_has_flag = government_is_holy_order
				government_has_flag = government_is_mercenary
			}
		}
	}

	greeting = positive
	notification_text = OFFER_FEALTY_INTERACTION_NOTIFICATION

	ai_min_reply_days = 5
	ai_max_reply_days = 10

	ai_accept = {
		base = 50
		# MAIN
		# Heretic/Infidel modifier.
		# Tier difference modifier.
		# Dejure modifier.
		# Distant/Remote Realm modifier.

		# MINOR
		# Rivalry modifier.
		# Same Dynasty modifier.
		# Cultural/Cultural Group modifiers.
		# Claimant modifier.

		# OPINION SCALES
		# Personality modifier.
		# Compare Opinion modifier.

		modifier = { # Different faith, no pluralism.
			desc = offer_vassalization_interaction_aibehavior_differentfaith_tt
			trigger = {
				scope:actor = {
					NOR = { # Of two different faiths AND the potential vassal's faith is not pluralistic.
						faith = scope:recipient.faith
						faith = { has_doctrine = doctrine_pluralism_pluralistic }
					}
				}
			}
			add = {
				value = -25
				if = {
					limit = {
						scope:actor.faith = {
							faith_hostility_level = {
								target = scope:recipient.faith
								value >= faith_hostile_level
							}
						}
					}
					add = -10
				}
				if = {
					limit = {
						scope:actor.faith = {
							faith_hostility_level = {
								target = scope:recipient.faith
								value >= faith_evil_level
							}
						}
					}
					add = -25
				}
			}
		}

		modifier = { # I am a King!
			desc = offer_fealty_interaction_aibehavior_amkingtier_tt
			trigger = {
				scope:actor = {
					highest_held_title_tier >= tier_kingdom
				}
			}
			add = -10
		}
		modifier = { # Wide difference in rank
			desc = offer_vassalization_interaction_aibehavior_widetitletier_tt
			trigger = {
				scope:actor = {
					tier_difference = {
						target = scope:recipient
						value > 1
					}
				}
			}
			add = 20
		}
		modifier = { # They are my Rightful Liege
			desc = offer_vassalization_interaction_aibehavior_rightfulvassaltitleholder_tt
			trigger = {
				scope:recipient = { is_rightful_liege_of = scope:actor }
			}
			add = 25
		}
		modifier = { # Distant Realm.
			desc = offer_vassalization_interaction_aibehavior_distantrealm_tt
			trigger = {
				scope:actor = {
					NOT = {
						any_neighboring_top_liege_realm_owner = { this = scope:recipient }
					}
				}
				scope:actor.capital_province = { squared_distance = { target = scope:recipient.capital_province value < 200000 } }
			}
			add = -15
		}
		modifier = { # Remote Realm.
			desc = offer_vassalization_interaction_aibehavior_remoterealm_tt
			trigger = {
				scope:actor = {
					NOT = {
						any_neighboring_top_liege_realm_owner = { this = scope:recipient }
					}
				}
				scope:actor.capital_province = { squared_distance = { target = scope:recipient.capital_province value >= 200000 } }
			}
			add = -25
		}

		# MINOR
		modifier = { # Rivalry modifier.
			desc = offer_vassalization_interaction_aibehavior_rival_tt
			trigger = {
				scope:recipient = {
					has_relation_rival = scope:actor
					NOT = { has_relation_nemesis = scope:actor }
				}
			}
			add = -10
		}
		modifier = { # Nemesis modifier.
			desc = offer_vassalization_interaction_aibehavior_nemesis_tt
			trigger = {
				scope:recipient = {
					has_relation_nemesis = scope:actor
				}
			}
			add = -30
		}
		modifier = { # Same Dynasty modifier.
			desc = offer_vassalization_interaction_aibehavior_dynasty_tt
			trigger = {
				scope:recipient = {
					dynasty = scope:actor.dynasty
				}
			}
			add = 10
		}

		modifier = { # Cultural Acceptance
			add = -5
			desc = cultural_acceptance_interaction_reason
			trigger = {
				scope:actor = {
					NOT = { has_same_culture_as = scope:recipient }
					culture = {
						cultural_acceptance = { target = scope:recipient.culture value < 50 }
					}
				}
			}
		}

		modifier = { # Same language
			add = 5
			desc = speaks_same_language_interaction_reason
			trigger = {
				scope:actor = {
					knows_language_of_culture = scope:recipient.culture
				}
			}
		}

		modifier = { # Claimant modifier.
			desc = offer_vassalization_interaction_aibehavior_claimant_tt
			trigger = {
				scope:actor.primary_title = {
					scope:recipient = {
						has_claim_on = prev
					}
				}
			}
			add = -15
		}

		# PERSONALITY
		ai_value_modifier = {
			ai_greed = 0.75
			min = 0
		}

		# OPINION INFLUENCE
		opinion_modifier = { # Compare Opinion modifier.
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.5
		}

		# CONTRACT OPTIONS
		modifier = {
			add = {
				value = -10
				if = {
					limit = { scope:recipient = { has_trait = zealous } }
					add = -30
				}
				else_if = {
					limit = { scope:recipient = { has_trait = cynical } }
					add = 30
				}
			}
			scope:actor = {	government_has_flag = government_is_feudal }
			scope:religious_taxation = yes
			desc = CONTRACT_RELIGIOUS_TAXATION_REASON
		}
		modifier = {
			add = -40
			scope:actor = {	government_has_flag = government_is_feudal }
			scope:low_obligations = yes
			desc = CONTRACT_LOW_TAXES_REASON
		}
		modifier = {
			add = 40
			scope:actor = {	government_has_flag = government_is_feudal }
			scope:high_obligations = yes
			desc = CONTRACT_HIGH_TAXES_REASON
		}
		modifier = {
			add = {
				value = -10
				if = {
					limit = { scope:recipient = { has_trait = zealous } }
					add = -30
				}
				else_if = {
					limit = { scope:recipient = { has_trait = cynical } }
					add = 30
				}
			}
			scope:actor = {	government_has_flag = government_is_clan }
			scope:religious_exemption_clan = yes
			desc = CONTRACT_RELIGIOUS_EXEMPTION_REASON
		}
		# EP3
		modifier = { # cowed from an emperor's impressive visit
			add = 10
			desc = speaks_same_language_interaction_reason
			trigger = {
				scope:actor = {
					knows_language_of_culture = scope:recipient.culture
				}
			}
		}
		#Confederation wants same-culture rulers
		modifier = {
			add = 100
			desc = CONFEDERATION_CULTURE_REASON
			scope:recipient = {
				is_confederation_member = yes
				culture = {
					this = scope:actor.culture
				}
			}
		}

		#Greatest of Khans and Mongol Emperor would prefer submission with tribute
		modifier = {
			add = -150
			desc = GOK_PREFER_SUBMISSION
			scope:recipient = {
				highest_held_title_tier >= tier_empire
				any_owned_story = {
					OR = {
						story_type = story_mongol_invasion
						story_type = story_greatest_of_khans
					}
				}
			}
		}
	}

	# Low starting obligations
	send_option = {
		is_shown = {
			scope:actor = {
				government_has_flag = government_is_feudal
			}
		}
		flag = low_obligations
		localization = low_obligations
	}

	# Medium starting obligations
	send_option = {
		is_shown = {
			scope:actor = {
				government_has_flag = government_is_feudal
			}
		}
		flag = normal_obligations
		localization = normal_obligations
		starts_enabled = { always = yes	}

	}

	# High starting obligations
	send_option = {
		is_shown = {
			scope:actor = {
				government_has_flag = government_is_feudal
			}
		}
		flag = high_obligations
		localization = high_obligations
	}

	# Medium-high starting obligations + religious protection
	send_option = {
		is_shown = {
			scope:actor = {
				government_has_flag = government_is_feudal
			}
		}
		is_valid = {
			NOT = { scope:recipient.faith = scope:actor.faith }
		}
		flag = religious_taxation
		localization = religious_taxation
	}

	# Religious exemption, for clans
	send_option = {
		is_shown = {
			scope:actor = {
				government_has_flag = government_is_clan
			}
		}
		is_valid = {
			NOT = { scope:recipient.faith = scope:actor.faith }
		}
		flag = religious_exemption_clan
		localization = religious_exemption
	}

	# Nothing, for clans
	send_option = {
		is_shown = {
			scope:actor = {
				government_has_flag = government_is_clan
			}
		}
		is_valid = {
			always = yes
		}
		flag = no_exemption_clan
		localization = no_exemption
	}

	send_options_exclusive = yes

	on_accept = {
		offer_fealty_interaction_effect = yes

		scope:actor = {
			trigger_event = char_interaction.0010
			if = {
				limit = {
					government_has_flag = government_is_administrative
					scope:recipient = { NOT = { government_has_flag = government_is_administrative } }
				}
				custom_tooltip = will_change_from_administrative_tt
				custom_tooltip = will_lose_administrative_government_type_tt
			}
			if = {
				limit = {
					scope:recipient = {
						is_confederation_member = yes
					}
				}
				if = {
					limit = {
						government_has_flag = government_is_nomadic
					}
					add_character_modifier = {
						modifier = mpo_confederation_member_modifier
						years = 5
					}
					every_vassal_or_below = {
						limit = {
							highest_held_title_tier >= tier_county
							government_has_flag = government_is_nomadic
						}
						add_character_modifier = {
							modifier = mpo_confederation_member_modifier
							years = 5
						}
					}
				}
				
				add_character_flag = {
					flag = new_confederate
					years = 3
				}
				every_vassal_or_below = {
					limit = {
						highest_held_title_tier >= tier_county
					}
					add_character_flag = {
						flag = new_confederate
						years = 3
					}
				}
			}
			
			# If you have a suzerain, they will get a lower opinion of you for not paying tribute anymore
			suzerain ?= {
				if = {
					limit = {
						this != scope:actor
						this != scope:recipient
					}
					add_opinion = {
						modifier = tributary_ceased_payments_opinion
						target = scope:actor
					}
				}
			}
		}
		scope:recipient = {
			if = {
				limit = {
					has_imprisonment_reason = scope:actor
				}
				consume_imprisonment_reasons = scope:actor
			}
			if = {
				limit = {
					has_revoke_title_reason = scope:actor
				}
				consume_revoke_title_reason = scope:actor
			}
			if = {
				limit = {
					has_banish_reason = scope:actor
				}
				consume_banish_reasons = scope:actor
			}
			if = {
				limit = {
					has_execute_reason = scope:actor
				}
				consume_execute_reasons = scope:actor
			}
		}
	}

	on_intermediary_accept = {
	}
	
	on_decline = {
		scope:actor = {
			trigger_event = char_interaction.0011
		}
	}
}

force_vote_in_succession_election_interaction = {
	category = interaction_category_uncategorized
	hidden = yes
	special_interaction = force_vote_in_succession_election
	icon = scroll_scales

	greeting = positive
	notification_text = FORCE_VOTE_INTERACTION_NOTIFICATION
	force_notification = yes

	desc = force_vote_in_succession_election_interaction_desc

	auto_accept = yes

	is_valid_showing_failures_only = {
		custom_description = {
			text = must_have_usable_hook_blocker
			subject = scope:actor
			object = scope:recipient

			scope:actor = {
				has_usable_hook = scope:recipient
			}
		}
	}

	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	on_accept = {
		scope:actor = {
			send_interface_message = {
				type = event_title_good
				title = force_vote_in_succession_election_interaction
				right_icon = scope:recipient

				show_as_tooltip = {
					scope:actor = {
						use_hook = scope:recipient
						custom_tooltip = msg_force_vote_in_succession_election_message
					}
				}
			}
			hidden_effect = {
				use_hook = scope:recipient
			}
		}
		
		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = minor_unity_gain
			DESC = clan_unity_voted.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}
}

set_primary_spouse_interaction = {
	category = interaction_category_diplomacy
	desc = set_primary_spouse_interaction_desc
	icon = icon_marriage

	auto_accept = yes

	is_shown = {
		scope:actor = {
			is_spouse_of = scope:recipient
		}
		NOT = {
			scope:actor.primary_spouse = scope:recipient
		}
	}
	is_valid_showing_failures_only = {
		scope:recipient = { is_busy_in_events_localised = yes }
		scope:recipient = {
			NOT = {
				has_trait = incapable
			}
		}
	}

	on_accept = {
		scope:actor.primary_spouse = {
			if = {
				limit = {
					has_opinion_modifier = {
						target = scope:actor
						modifier = spouse_made_primary_opinion
					}
				}
				remove_opinion = {
					modifier = spouse_made_primary_opinion
					target = scope:actor
				}
			}
			add_opinion = {
				target = scope:actor
				modifier = spouse_made_secondary_opinion
			}
			hidden_effect = {
				send_interface_toast = {
					type = event_toast_effect_bad
					title = set_primary_spouse_interaction_toast
					left_icon = scope:actor
					right_icon = scope:recipient

					custom_tooltip = set_primary_spouse_interaction_toast_removed
				}
			}
		}
		scope:actor = {
			if = {
				limit = {
					scope:actor.primary_spouse = {
						is_lowborn = no
					}
					scope:recipient = {
						is_lowborn = yes
					}
				}
				add_legitimacy = {
					value = medium_legitimacy_loss
					multiply = scope:actor.primary_title.tier
				}
				every_vassal_or_below = {
					limit = { has_vassal_stance = courtly }
					custom = every_courtly_vassal
					add_opinion = {
						modifier = married_lowborn_opinion
						target = scope:actor
						opinion = -50
					}
				}
				every_vassal_or_below = {
					limit = { has_vassal_stance = glory_hound }
					custom = every_glory_hound_vassal
					add_opinion = {
						modifier = married_lowborn_opinion
						target = scope:actor
						opinion = -30
					}
				}	
			}
			set_primary_spouse = scope:recipient
			hidden_effect = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = set_primary_spouse_interaction_toast
					left_icon = scope:actor
					right_icon = scope:recipient

					custom_tooltip = set_primary_spouse_interaction_toast_changed
				}
			}
		}
		scope:recipient = {
			hidden_effect = {
				send_interface_toast = {
					type = event_toast_effect_good
					title = set_primary_spouse_interaction_toast
					left_icon = scope:actor
					right_icon = scope:recipient

					custom_tooltip = set_primary_spouse_interaction_toast_added
				}
			}

			if = {
				limit = {
					has_opinion_modifier = {
						target = scope:actor
						modifier = spouse_made_secondary_opinion
					}
				}
				remove_opinion = {
					modifier = spouse_made_secondary_opinion
					target = scope:actor
				}
			}
			add_opinion = {
				target = scope:actor
				modifier = spouse_made_primary_opinion
			}
		}
	}

	ai_targets = {
		ai_recipients = spouses
	}
	ai_target_quick_trigger = {
		adult = yes
	}
	ai_frequency = 72

	ai_potential = {
		any_spouse = {
			count >= 2
		}
	}

	ai_will_do = {
		base = 0

		modifier = {
			add = 100
			scope:recipient = {
				is_lowborn = no
				sum_of_all_skills_value > scope:actor.primary_spouse.sum_of_all_skills_value
			}
			scope:actor = {
				NOR = {
					has_relation_friend = scope:actor.primary_spouse
					has_relation_lover = scope:actor.primary_spouse
				}
			}
		}
	}
}

grant_independence_interaction = {
	category = interaction_category_vassal
	force_notification = yes
	greeting = positive
	notification_text = GRANT_INDEPENDENCE_INTERACTION_NOTIFICATION
	icon = independence
	interface_priority = 120

	desc = grant_independence_interaction_desc

	is_shown = {
		scope:actor = {
			is_confederation_member = no
		}
		scope:recipient = {
			is_vassal_of = scope:actor
		}
		NOT = { scope:recipient = scope:actor }
	}

	is_valid_showing_failures_only = {
		NOT = { scope:actor = { is_at_war_with = scope:recipient } }
		scope:actor = {
			is_independent_ruler = yes
			NOT = {
				is_at_war = yes
			}
		}
		custom_description = {
			text = is_at_war_with_another_vassal
			object = scope:recipient
			NOT = {
				scope:actor = {
					any_vassal_or_below = {
						is_at_war_with = scope:recipient
					}
				}
			}
		}
		custom_description = {
			text = is_de_jure_vassal_check
			object = scope:recipient
			
			trigger_if = { # Admin rulers can grant tribal vassals independence regardless of de jure
				limit = {
					scope:actor = { government_has_flag = government_is_administrative }
					scope:recipient = { government_has_flag = government_is_tribal }
				}
				# Always possible
			}
			trigger_else = {
				NOT = { #Cannot be used against de jure vassals
					scope:recipient.primary_title = {
						any_this_title_or_de_jure_above = {
							holder = scope:actor
						}
					}
				}
			}
			
		}
		custom_tooltip = {
			text = can_only_remove_diarch_by_elevating_them.tt
			NOT = { scope:recipient ?= scope:actor.diarch }
		}
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			stress_impact = {
				ambitious = medium_stress_impact_gain
				arrogant = minor_stress_impact_gain
				greedy = minor_stress_impact_gain
			}
			hidden_effect = {
				send_interface_toast = {
					type = event_toast_effect_neutral
					title = grant_vassal_independence_interaction_toast
					left_icon = scope:actor
					right_icon = scope:recipient

					custom_tooltip = grant_vassal_independence_interaction_toast_desc

					# Struggle Parameter
					if = {
						limit = {
							exists = dynasty
							NOT = {
								any_held_title = {
 									is_de_jure_liege_or_above_target = scope:recipient.primary_title
								}
							}
							any_character_struggle = {
								involvement = involved
								has_struggle_phase_parameter = granting_independence_to_non_dejure_gives_renown
							}
						}
						dynasty = {
							add_dynasty_prestige = medium_dynasty_prestige_value
						}
					}
				}
			}
		}

		scope:recipient = {
			#Send notifications
			if = {
				limit = {
					any_liege_or_above = {
						is_ai = no
						NOT = { this = scope:actor }
					}
				}
				every_liege_or_above = {
					limit = {
						is_ai = no
						NOT = { this = scope:actor }
					}
					trigger_event = vassal_interaction.0023
				}
			}
			if = {
				limit = {
					any_liege_or_above = {
						any_vassal = {
							is_ai = no
							NOR = {
								this = scope:recipient
								this = scope:actor
							}
						}
					}
				}
				every_liege_or_above = {
					limit = {
						any_vassal = {
							is_ai = no
							NOR = {
								this = scope:recipient
								this = scope:actor
							}
						}
					}
					every_vassal = {
						limit = {
							is_ai = no
							NOT = { this = scope:recipient }
						}
						trigger_event = {
							id = vassal_interaction.0022
							days = 3
						}
					}
				}
			}

			add_opinion = {
				target = scope:actor
				modifier = granted_independence_opinion
			}

			add_truce_both_ways = {
				character = scope:actor
				days = 3650
				name = TRUCE_GRANT_INDEPENDENCE
			}

			create_title_and_vassal_change = {
				type = independency
				save_scope_as = change
				add_claim_on_loss = yes
			}
			becomes_independent = {
				change = scope:change
			}

			resolve_title_and_vassal_change = scope:change
		}

		# Struggle Catalysts.
		scope:actor = {
			if = {
				limit = {
					catalyst_gave_independence_to_powerful_diff_faith_culture_vassal_preliminary_trigger = {
						CHAR1 = scope:actor
						CHAR2 = scope:recipient
					}
					any_character_struggle = {
						involvement = involved
						activate_struggle_catalyst_secondary_character_involvement_either_trigger = {
							CATALYST = catalyst_gave_independence_to_powerful_diff_faith_culture_vassal
							CHAR = scope:recipient
						}
					}
				}
				every_character_struggle = {
					involvement = involved
					limit = {
						activate_struggle_catalyst_secondary_character_involvement_either_trigger = {
							CATALYST = catalyst_gave_independence_to_powerful_diff_faith_culture_vassal
							CHAR = scope:recipient
						}
					}
					activate_struggle_catalyst = {
						catalyst = catalyst_gave_independence_to_powerful_diff_faith_culture_vassal
						character = scope:actor
					}
				}
			}

			if = {
				limit = {
					NOT = {
						any_held_title = {
							is_de_jure_liege_or_above_target = scope:recipient.primary_title
						}
					}
					any_character_struggle = {
						involvement = involved
						activate_struggle_catalyst_secondary_character_involvement_either_trigger = {
							CATALYST = catalyst_independence_from_non_dejure_vassal
							CHAR = scope:recipient
						}
					}
				}
				every_character_struggle = {
					involvement = involved
					limit = {
						activate_struggle_catalyst_secondary_character_involvement_either_trigger = {
							CATALYST = catalyst_independence_from_non_dejure_vassal
							CHAR = scope:recipient
						}
					}
					activate_struggle_catalyst = {
						catalyst = catalyst_independence_from_non_dejure_vassal
						character = scope:actor
					}
				}
			}
		}

		# Grant independence to non de_jure


		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = medium_unity_loss
			DESC = clan_unity_grant_independence.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	ai_will_do = {
		base = 0 #The AI should never do this!

		# Except in the context of Struggle
		modifier = {
			scope:recipient = {
				any_character_struggle = {
					involvement = involved
				}
			}
			scope:actor = {
				any_character_struggle = {
					involvement = involved
				}
				NOT = {
					any_held_title = {
						is_de_jure_liege_or_above_target = scope:recipient.primary_title
					}
				}
			}
			add = {
				value = 0
				if = {
					limit = {
						scope:actor = {
							any_character_struggle = {
								phase_has_catalyst = catalyst_independence_from_non_dejure_vassal
							}
							has_character_flag = agenda_towards_escalation
						}
					}
					add = -50
				}
				else_if = {
					limit = {
						scope:actor = {
							any_character_struggle = {
								phase_has_catalyst = catalyst_independence_from_non_dejure_vassal
							}
						}
					}
					add = 100
				}
			}
		}

		# Unity modifiers
		evaluate_action_decreasing_house_unity = {
			VALUE = 10
		}
	}
}

expose_secret_interaction = {
	interface_priority = 120
	common_interaction = no
	category = interaction_category_hostile
	interface = blackmail
	icon = secret

	desc = expose_secret_interaction_desc

	is_shown = {
		scope:recipient = {
			any_secret = {
				is_known_by = scope:actor
			}
			NOT = { this = scope:actor }
			age > 10
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = { is_busy_in_events_localised = yes }
	}

	on_accept = {
		scope:actor = {
			if = {
				limit = {
					is_landless_adventurer = yes
					has_perk = court_of_shadows_perk
				}
				add_prestige = {
					value = 100
					multiply = {
						value = scope:recipient.highest_held_title_tier
						add = 1
					}
					min = 50
				}
			}
			if = {
				limit = {
					exists = scope:target
				}
				scope:target = {
					expose_secret = scope:actor
				}
			}
			else = {
				every_known_secret = {
					limit = {
						secret_owner = scope:recipient
					}
					expose_secret = scope:actor
				}
			}

			stress_impact = {
				honest = minor_stress_impact_loss
				just = minor_stress_impact_loss
				shy = miniscule_stress_impact_gain
			}
		}

		scope:recipient = {
			stress_impact = {
				honest = minor_stress_impact_loss
				just = minor_stress_impact_loss
				deceitful = minor_stress_impact_gain
			}
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = major_unity_loss
			DESC = clan_unity_secret_exposure.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	auto_accept = yes

	ai_will_do = {
		base = 0

		# Struggle
		modifier = {
			scope:recipient = {
				any_character_struggle = {
					involvement = involved
				}
				is_important_or_vip_struggle_character = yes
			}
			scope:actor = {
				any_character_struggle = {
					involvement = involved
				}
			}
			add = {
				value = 0
				if = {
					limit = {
						scope:actor = {
							any_character_struggle = {
								phase_has_catalyst = catalyst_reveal_secret_important
							}
							has_character_flag = agenda_towards_escalation
						}
					}
					add = 200
				}
				else_if = {
					limit = {
						scope:actor = {
							any_character_struggle = {
								phase_has_catalyst = catalyst_reveal_secret_important
							}
						}
					}
					add = -100
				}
			}
		}
		modifier = {
			scope:recipient = {
				any_character_struggle = {
					involvement = involved
				}
				has_trait = fp3_struggle_supporter
			}
			scope:actor = {
				any_character_struggle = {
					involvement = involved
				}
			}
			add = {
				value = 0
				if = {
					limit = {
						scope:actor = {
							any_character_struggle = {
								phase_has_catalyst = catalyst_reveal_secret_supporter
							}
							has_trait = fp3_struggle_detractor
						}
					}
					add = 200
				}
				else_if = {
					limit = {
						scope:actor = {
							any_character_struggle = {
								phase_has_catalyst = catalyst_reveal_secret_supporter
							}
						}
					}
					add = -100
				}
			}
		}
		modifier = {
			scope:recipient = {
				any_character_struggle = {
					involvement = involved
				}
				has_trait = fp3_struggle_detractor
			}
			scope:actor = {
				any_character_struggle = {
					involvement = involved
				}
			}
			add = {
				value = 0
				if = {
					limit = {
						scope:actor = {
							any_character_struggle = {
								phase_has_catalyst = catalyst_reveal_secret_detractor
							}
							has_trait = fp3_struggle_supporter
						}
					}
					add = 200
				}
				else_if = {
					limit = {
						scope:actor = {
							any_character_struggle = {
								phase_has_catalyst = catalyst_reveal_secret_detractor
							}
						}
					}
					add = -100
				}
			}
		}

		# Unity modifiers
		evaluate_action_decreasing_house_unity = {
			VALUE = 100
		}
	}
}
